<?php
namespace Export\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
    	$this -> display();
    }
	
    public function get_taback(){
		$sid = I('sid');
		$cid = I('cid');
		if(!$sid) _apiReturn(0,'学校ID不能为空',$info,$url);
		if(!I('year')) _apiReturn(0,'年份不能为空',$info,$url);
		if(!I('month')) _apiReturn(0,'月份不能为空',$info,$url);
		$Y = I('year');//获取年，示例，真实环境从前端获取数据  
		$m = I('month');//获取月，示例，真实环境从前端获取数据  
		$p = I('p') ? I('p') : 1;
		$row = I('row') ? I('row') : 10;
		$month = $Y."-".$m;//当前年月  
		$m = intval($m)+1;
		$othermonth = $Y."-".$m;//当前年月  
		$month_start = strtotime($month);//指定月份月初时间戳  
		$month_end = strtotime($othermonth)-1;//指定月份月末时间戳  
		// $map['dateline'] = array(array('egt',$month_start),array('elt',$month_end));
		//1493568000---1496246399  17/5/1-17/5/31
        $map['dateline'] = array('between',array($month_start,$month_end));
        $map['sid'] = $sid;
		if($cid){
			$map['cid'] = $cid;
		}
        // $m = D('Tabstat');
        $m = M('Tabstat','nu_',C('DB_HOST_ONE'));
		$data = $m->where($map)->limit(($p-1)*$row,$row)->order('dateline desc')->select();
		foreach($data as $t){
			$t['dateline'] = date('Y-m-d H:i:s', $t['dateline']);
			$result[] = $t;
		}
		$info['data'] = $result;
		$info['page']['total'] = $m->where($map)->count();
		$info['page']['cur'] = $p;
        $info['page']['row'] = $row;
        _apiReturn(1,'获取成功',$info,$url);
	}
}